# 参考资料：
# [1] [图像处理核函数：之高斯核的生成方法 python](https://blog.csdn.net/jasneik/article/details/108150217)
# [2] [简单易懂的高斯滤波](https://www.jianshu.com/p/73e6ccbd8f3f)
import numpy as np


# 高斯核生成函数
def creat_gauss_kernel(kernel_size=3, sigma=1, k=1):
    if sigma == 0:
        sigma = ((kernel_size - 1) * 0.5 - 1) * 0.3 + 0.8
    X = np.linspace(-k, k, kernel_size)
    Y = np.linspace(-k, k, kernel_size)
    x, y = np.meshgrid(X, Y)
    x0 = 0
    y0 = 0
    gauss = 1/(2*np.pi*sigma**2) * \
        np.exp(- ((x - x0)**2 + (y - y0)**2) / (2 * sigma**2))
    return gauss


print(creat_gauss_kernel())
